import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


const routes = [
  // {
  //   path: '/',
  //   name: 'home',
  //   component: HomeView
  // },
  
  {
    path: '/adminMain',
    name: 'AdminMain',
    component: () => import('../views/AdminMain.vue'),
    redirect:'adminMain/home',
    children:[
      {
        path:'home',
        name:'AHome',
        meta: { name : '系统首页' },
        component: () => import('../views/admin/Home'),
      },
      {
        path:'updatePwd',
        name:'AUpdatePwd',
        meta: { name : '管理员修改密码' },
        component: () => import('../views/admin/UpdatePwd'),
      },
      {
        path:'studentMsg',
        name:'AStudentMsg',
        meta: { name : '管理员学生管理' },
        component: () => import('../views/admin/StudentMsg'),
      },
      {
        path:'teacherMsg',
        name:'ATeacherMsg',
        meta: { name : '管理员教师管理' },
        component: () => import('../views/admin/TeacherMsg'),
      },
      {
        path:'laborMsg',
        name:'ALaborMsg',
        meta: { name : '管理员实验室管理' },
        component: () => import('../views/admin/LaborMsg'),
      },{
        path:'planMsg',
        name:'APlanMsg',
        meta: { name : '管理员实验计划管理' },
        component: () => import('../views/admin/PlanMsg'),
      },{
        path:'notice',
        name:'ANotice',
        meta: { name : '管理员公告管理' },
        component: () => import('../views/notice/Notice'),
      },{
        path:'device',
        name:'ADevice',
        meta: { name : '管理员实验室设备管理' },
        component: () => import('../views/admin/Device'),
      }
    ]
  },
  {
    path:'/about',
    name:'AboutView',
    component: () => import('../views/AboutView.vue')
  },
  {
    path:'/studLogin',
    name:'StudLoginView',
    component: () => import('../views/StudLoginView.vue')
  },
  {
    path:'/adminLogin',
    name:'AdminLoginView',
    component: () => import('../views/AdminLoginView.vue')
  },
  {
    path:'/teacherLogin',
    name:'TeachLoginView',
    component: () => import('../views/TeacherLogin.vue')
  },
  {
    path:'/studMain',
    name:'StudView',
    component: () => import('../views/StudMain.vue'),
    redirect:'studMain/home',
    children:[
      {
        path:'home',
        name:'SHome',
        meta: { name : '系统首页' },
        component: () => import('../views/student/Home'),
      },
      {
        path:'updatePwd',
        name:'SUpdatePwd',
        meta: { name : '学生修改密码' },
        component: () => import('../views/student/UpdatePwd'),
      },{
        path:'homework',
        name:'SHomework',
        meta: { name : '学生实验作业' },
        component: () => import('../views/student/Homework'),
      }

    ]
  },
  {
    path:'/teacherMain',
    name:'TeacherMain',
    component: () => import('../views/TeacherMain.vue'),
    redirect:'teacherMain/home',
    children:[
      {
        path:'home',
        name:'THome',
        meta: { name : '系统首页' },
        component: () => import('../views/teacher/Home'),
      },
      {
        path:'updatePwd',
        name:'TUpdatePwd',
        meta: { name : '教师修改密码' },
        component: () => import('../views/teacher/UpdatePwd'),
      },
      {
        path:'planMsg',
        name:'TPlanMsg',
        meta: { name : '教师实验计划管理' },
        component: () => import('../views/teacher/PlanMsg'),
      },
      {
        path:'homework',
        name:'THomework',
        meta: { name : '教师学生实验报告管理' },
        component: () => import('../views/teacher/Homework'),
      }
    ]

  },
  {
    path: '/',
    redirect: '/adminLogin'
  }

]

const router = new VueRouter({
  mode: 'history',
  routes
})


 
// 解决重复点击导航时，控制台出现报错
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default router
